home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performSetBreakdown.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  10.6 KB  |  405 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Dec 3, 1996
  22. //
  23. //  Description:
  24. //      This is a helper script to perform the setKey -breakdown true command
  25. //    using the various options that have been set
  26. //
  27. //  Input Arguments:
  28. //        int action        0 - just execute the command
  29. //                        1 - show the option box dialog
  30. //                        2 - return the drag command
  31. //
  32. //  Return Value:
  33. //      None.
  34. //
  35.  
  36. proc setOptionVars (int $forceFactorySettings)
  37. {
  38.     // setBreakdownWhich:
  39.     //     1 : set keyframes on all keyable attrs
  40.     //     2 : set keyframes on all manip handle attrs
  41.     //     3 : set keyframes on current manip handle
  42.     //
  43.     if( $forceFactorySettings || !`optionVar -exists setBreakdownWhich` ) {
  44.         optionVar -intValue setBreakdownWhich 1;
  45.     } 
  46.  
  47.     if( $forceFactorySettings || !`optionVar -exists setBreakdownPrompt` ) {
  48.         optionVar -intValue setBreakdownPrompt 0;
  49.     } 
  50.  
  51.     if( $forceFactorySettings || !`optionVar -exists setBreakdownHierarchy`) {
  52.         optionVar -intValue setBreakdownHierarchy 0;
  53.     }
  54.     // use channel box attrs
  55.     //
  56.     if ($forceFactorySettings || !`optionVar -exists setBreakdownUseChannelBox`) {
  57.         optionVar -intValue setBreakdownUseChannelBox 0;
  58.     }
  59.     // -controlPoints
  60.     //
  61.     if ($forceFactorySettings || !`optionVar -exists setBreakdownControlPoints`) {
  62.         optionVar -intValue setBreakdownControlPoints 0;
  63.     }
  64.     // -shape
  65.     //
  66.     if ($forceFactorySettings || !`optionVar -exists setBreakdownShapes`) {
  67.         optionVar -intValue setBreakdownShapes 1;
  68.     }
  69. }
  70.  
  71. global proc setBreakdownSetup (string $parent, int $forceFactorySettings)
  72. {
  73.     // Retrieve the option settings
  74.     //
  75.     setOptionVars( $forceFactorySettings );
  76.  
  77.     setParent $parent;
  78.  
  79.     // Query the optionVar's and set the values into the controls
  80.     //    
  81.     int $whichAttrs = `optionVar -query setBreakdownWhich`;
  82.     switch($whichAttrs)
  83.     {
  84.         case 1:
  85.             radioButtonGrp -edit -sl 1 allAttrsRB;
  86.             break;
  87.         case 2:
  88.             radioButtonGrp -edit -sl 1 allManipAttrsRB;
  89.             break;
  90.         case 3:
  91.             radioButtonGrp -edit -sl 1 curManipHandleRB;
  92.             break;
  93.     }
  94.  
  95.     if( `optionVar -query setBreakdownPrompt` == 1 ) {
  96.         radioButtonGrp -e -select 2 setBreakdownPrompt;
  97.     } else {
  98.         radioButtonGrp -e -select 1 setBreakdownPrompt;
  99.     }
  100.  
  101.     if (`optionVar -query setBreakdownHierarchy` == 1) {
  102.         radioButtonGrp -edit -select 2 hierarchyRB;
  103.     } else {
  104.         radioButtonGrp -edit -select 1 hierarchyRB;
  105.     }
  106.  
  107.     if (`optionVar -query setBreakdownUseChannelBox` == 1) {
  108.         radioButtonGrp -edit -select 2 channelsRB;
  109.     } else {
  110.         radioButtonGrp -edit -select 1 channelsRB;
  111.     }
  112.  
  113.     checkBoxGrp -edit -value1 `optionVar -query setBreakdownControlPoints` controlCB;
  114.     checkBoxGrp -edit -value1 `optionVar -query setBreakdownShapes` shapesCB;
  115.  
  116.     breakdownEnabling $parent ($whichAttrs == 1);
  117. }
  118.  
  119. global proc setBreakdownCallback (string $parent, int $doIt, string $selectionConnection)
  120. //
  121. // Description:
  122. //    Set the optionVar's from the control values, and then perform
  123. //    the command
  124. //
  125. {
  126.     setParent $parent;
  127.  
  128.     if( `radioButtonGrp -q -sl allManipAttrsRB` == 1) {
  129.         optionVar -intValue setBreakdownWhich 2;
  130.     } else if( `radioButtonGrp -q -sl curManipHandleRB` == 1 ) {
  131.         optionVar -intValue setBreakdownWhich 3;
  132.     } else {
  133.         optionVar -intValue setBreakdownWhich 1;
  134.     }
  135.  
  136.     if (`radioButtonGrp -query -select setBreakdownPrompt` == 2) {
  137.         optionVar -intValue setBreakdownPrompt 1;
  138.     } else {
  139.         optionVar -intValue setBreakdownPrompt 0;
  140.     }
  141.  
  142.     if (`radioButtonGrp -query -select hierarchyRB` == 2) {
  143.         optionVar -intValue setBreakdownHierarchy 1;
  144.     } else {
  145.         optionVar -intValue setBreakdownHierarchy 0;
  146.     }
  147.  
  148.     if (`radioButtonGrp -query -select channelsRB` == 2) {
  149.         optionVar -intValue setBreakdownUseChannelBox 1;
  150.     } else {
  151.         optionVar -intValue setBreakdownUseChannelBox 0;
  152.     }
  153.  
  154.     optionVar -intValue setBreakdownControlPoints
  155.                             `checkBoxGrp -query -value1 controlCB`;
  156.     optionVar -intValue setBreakdownShapes
  157.                             `checkBoxGrp -query -value1 shapesCB`;
  158.  
  159.     if ($doIt)
  160.     {    
  161.         performSetBreakdown 0 $selectionConnection;
  162.         string $tmpCmd = "performSetBreakdown 0 \"" + $selectionConnection + "\"";
  163.         addToRecentCommandQueue $tmpCmd "SetBreakdown";
  164.     }
  165. }
  166.  
  167.  
  168. global proc breakdownEnabling(string $parent, int $state)
  169. {
  170.     setParent $parent;
  171.  
  172.     radioButtonGrp -edit -enable $state hierarchyRB;
  173.     radioButtonGrp -edit -enable $state channelsRB;
  174.  
  175.     breakdownChannelsEnabling $parent 
  176.         ($state && (`radioButtonGrp -query -select channelsRB` == 1));
  177. }
  178.  
  179. global proc breakdownChannelsEnabling(string $parent, int $state)
  180. {
  181.     setParent $parent;
  182.  
  183.     checkBoxGrp -edit -enable $state controlCB;
  184.     checkBoxGrp -edit -enable $state shapesCB;
  185. }
  186.  
  187. proc string setBreakdownWidgets( string $parent )
  188. {
  189.     setParent $parent;
  190.     
  191.     string $tabForm = `columnLayout -adjustableColumn true`;
  192.  
  193.     // Make a collection of 3 radio groups instead of one with 3 options,
  194.     // so that we can line up the text on separate lines
  195.     //
  196.     radioButtonGrp -numberOfRadioButtons 1
  197.         -label "Set Breakdowns on"
  198.         -label1 "All Keyable Attributes"
  199.         -cc ("breakdownEnabling "+ $parent+" #1")
  200.         allAttrsRB;
  201.     
  202.     radioButtonGrp -numberOfRadioButtons 1
  203.         -label1 "All Manipulator Handles"
  204.         -shareCollection allAttrsRB
  205.         allManipAttrsRB;
  206.  
  207.     radioButtonGrp -numberOfRadioButtons 1
  208.         -label1 "Current Manipulator Handle"
  209.         -shareCollection allAttrsRB
  210.         curManipHandleRB;
  211.  
  212.     radioButtonGrp -numberOfRadioButtons 2
  213.         -label  "Set Breakdowns at"
  214.         -label1 "Current Time" 
  215.         -label2 "Prompt"
  216.         setBreakdownPrompt;
  217.  
  218.     separator -style "in";
  219.  
  220.     radioButtonGrp -numberOfRadioButtons 2
  221.            -label Hierarchy -label1 "Selected" -label2 "Below"
  222.            hierarchyRB;
  223.  
  224.     radioButtonGrp -numberOfRadioButtons 2 -label "Channels"
  225.                 -label1 "All Keyable" 
  226.                 -label2 "From Channel Box"
  227.                 -cc1 ("breakdownChannelsEnabling " + $parent + " #1")
  228.                 channelsRB;
  229.  
  230.     checkBoxGrp -label "Control Points" -ncb 1 -label1 "" controlCB;
  231.     checkBoxGrp -label "Shapes" -ncb 1 -label1 "" shapesCB;
  232.  
  233.     return $tabForm;
  234. }
  235.  
  236. global proc setBreakdownOptions (string $selectionConnection)
  237. {
  238.     string $commandName = "setBreakdown";
  239.  
  240.     string $applyTitle = "Set Breakdown";
  241.     
  242.     // Build the option box "methods"
  243.     //
  244.     string $callback = ($commandName + "Callback");
  245.     string $setup = ($commandName + "Setup");
  246.  
  247.     //    Get the option box.
  248.     //
  249.     //  The value returned is the name of the layout to be used as
  250.     //    the parent for the option box UI.
  251.     //
  252.     string $layout = getOptionBox();
  253.     setParent $layout;
  254.  
  255.     setOptionBoxCommandName($commandName);
  256.  
  257.     setUITemplate -pushTemplate DefaultTemplate;
  258.     waitCursor -state 1;
  259.     tabLayout -scr true -tv false;    // To get the scroll bars
  260.  
  261.     string $parent = `columnLayout -adjustableColumn 1`;
  262.  
  263.     setBreakdownWidgets $parent;
  264.  
  265.     waitCursor -state 0;
  266.     setUITemplate -popTemplate;
  267.  
  268.     //    'Apply' button.
  269.     //
  270.     string $applyBtn = getOptionBoxApplyBtn();
  271.     button -edit
  272.         -label $applyTitle
  273.         -command ($callback + " " + $parent + " " + 1 + " \"" + $selectionConnection + "\"")
  274.         $applyBtn;
  275.  
  276.     //    'Save' button.
  277.     //
  278.     string $saveBtn = getOptionBoxSaveBtn();
  279.     button -edit 
  280.         -command ($callback + " " + $parent + " " + 0 + " \"" + $selectionConnection + "\"; hideOptionBox")
  281.         $saveBtn;
  282.  
  283.     //    'Reset' button.
  284.     //
  285.     string $resetBtn = getOptionBoxResetBtn();
  286.     button -edit 
  287.         -command ($setup + " " + $parent + " " + 1)
  288.         $resetBtn;
  289.  
  290.     //    Set the option box title.
  291.     //
  292.     setOptionBoxTitle("Set Breakdown Options");
  293.  
  294.     //    Customize the 'Help' menu item text.
  295.     //
  296.     setOptionBoxHelpTag( "SetBreakdown" );
  297.  
  298.     //    Set the current values of the option box.
  299.     //
  300.     eval (($setup + " " + $parent + " " + 0));    
  301.     
  302.     //    Show the option box.
  303.     //
  304.     showOptionBox();
  305. }
  306.  
  307.  
  308. //
  309. //  Procedure Name:
  310. //      assembleCmd
  311. //
  312. //  Description:
  313. //        Construct the command that will apply the option box values.
  314. //
  315. //  Input Arguments:
  316. //      None.
  317. //
  318. //  Return Value:
  319. //      None.
  320. //
  321. proc string assembleCmd(string $selectionConnection)
  322. {
  323.     string $cmd;
  324.  
  325.     setOptionVars(false);
  326.  
  327.     // doSetKeyframeArgList takes a string array 
  328.     //
  329.     $cmd =    "doSetKeyframeArgList 3 { " +
  330.                 "\"" + `optionVar -query setBreakdownWhich` + "\"" +
  331.                 ",\"" + `optionVar -query setBreakdownHierarchy` + "\"" +
  332.                 ",\"" + `optionVar -query setBreakdownUseChannelBox` + "\"" +
  333.                 ",\"" + `optionVar -query setBreakdownControlPoints` + "\"" +
  334.                 ",\"" + `optionVar -query setBreakdownShapes` + "\"" +
  335.                 ",\"" + `optionVar -query setBreakdownPrompt` + "\"" +
  336.                 ",\"" + true + "\"" +
  337.                 ",\"" + $selectionConnection + "\"" +
  338.             " };";
  339.  
  340.     return $cmd;
  341. }
  342.  
  343. //
  344. //  Procedure Name:
  345. //      performSetBreakdown
  346. //
  347. //  Description:
  348. //        Perform the 'setKeyframe -breakdown true' command using the corresponding 
  349. //        option values.  This procedure will also show the option box
  350. //        window if necessary as well as construct the command string
  351. //        that will invoke the 'setKeyframe -breakdown true' command with the current 
  352. //        option box values.
  353. //
  354. //  Input Arguments:
  355. //      0 - Execute the command.
  356. //      1 - Show the option box dialog.
  357. //      2 - Return the command.
  358. //
  359. //  Return Value:
  360. //      None.
  361. //
  362. global proc string performSetBreakdown (int $action, string $selectionConnection)
  363. {
  364.     string $cmd = "";
  365.  
  366.     switch ($action) {
  367.  
  368.         //    Execute the command.
  369.         //
  370.         case 0:
  371.             //    Retrieve the option settings
  372.             //
  373.             setOptionVars(false);
  374.  
  375.             //    Get the command.
  376.             //
  377.             $cmd = assembleCmd ($selectionConnection);
  378.  
  379.             //    Execute the command with the option settings.
  380.             //
  381.             eval($cmd);
  382.  
  383.             break;
  384.  
  385.         //    Show the option box.
  386.         //
  387.         case 1:
  388.             setBreakdownOptions ($selectionConnection);
  389.             break;
  390.  
  391.         //    Return the command string.
  392.         //
  393.         case 2:
  394.             //    Retrieve the option settings.
  395.             //
  396.             setOptionVars (false);
  397.  
  398.             //    Get the command.
  399.             //
  400.             $cmd = assembleCmd ($selectionConnection);
  401.             break;
  402.     }
  403.     return $cmd;
  404. }
  405.